﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="giftdetail.aspx.cs" Inherits="giftdetail" EnableViewState="false" %>
<!DOCTYPE html>
<html>
<head>
    <title>商品详情</title>
</head>
<body>
    <div>
        <section data-role="page" data-theme="b" id="giftdetail_main">
            <div style="padding:20px 10px;" id="giftdetail_content">
                <div class="detail-main">
                    <div class="detail_row">
                	    <!--left-->
                        <div class="row_item row_item-left">
                            <img runat="server" id="giftdetail_gift" style="border-radius:8px;" />
                        </div>
                        <!--right-->
                        <div class="row_item row_item-right">
                            <strong style="font-size:14px;" runat="server" id="giftdetail_GiftName"></strong>
                            <p>兑换积分：&nbsp;&nbsp;<span class="discountPrice" runat="server" id="giftdetail_GiftExchangePoint">1526</span> 积分</p>
                            <div>
                                <span>购买数量：</span>
                                <span class="minus" id="minus" style="position:relative;top:3px;"><img src="images/minus.png" /></span>
                                <span class="number" id="number">1</span>
                                <span class="plus" id="plus" style="position:relative;top:3px;"><img src="images/plus.png" /></span>
                            </div>
                        </div>
                        <!--right end-->
                    </div>
                </div>
                
                <a data-role="button" data-theme="b" id="giftcard" style="background:#09f;border-radius:8px;margin:0px 3px;border:0px;">加入礼品车</a>
             
                <a href="#giftscard" data-load="giftscard.aspx" data-role="button" data-theme="b" style="display:none;" id="go">前去礼品车</a>
                <a href="#giftlist" data-load="giftlist.aspx" data-role="button" data-theme="b" style="display:none;" id="goBack">返回礼品列表页</a>
              
                <input type="hidden" runat="server" id="txtGiftID" />
               <!-- 
                <div class="goodsDesc">
                    <p runat="server" id="giftdetail_GiftRemark" style="line-height:1.6;text-indent:2em;"></p>
                </div>-->
            </div>
        
            <script type="text/javascript">
                $("#minus,#plus").click(function () {
                    var type = $(this).attr("id");
                    var number = parseInt($("#number").text());
                    if (type == "plus") { number++; } else { number <= 1 ? 1 : number--; }
                    $("#number").text(number);
                })

                $("#giftcard").click(function () {
                    var number = parseInt($("#number").text());
                    var mem_point = parseInt("<%=MemPoint %>");
                    var gift_point = parseInt("<%=point %>");
                    if (number * gift_point > mem_point) {
                        if (number > 1) {
                            var sf = "loader(true,'您的积分不足，无法兑换" + number + "个该礼品')";
                            setTimeout(sf, 500);
                        } else {
                            setTimeout('loader(true,"您的积分不足，无法完成兑换")', 500);
                        }
                        setTimeout('loader(false)', 1500);
                        return;
                    } else {
                        var strKey = "";
                        var txtGiftID = $("#txtGiftID");
                        var getData = "";
                        for (var i = 0; i < localStorage.length; i++) {
                            strKey = localStorage.key(i);
                            if (strKey.substring(0, 5) == "gift_") {
                                getData = JSON.parse(xxl.xd.getValue(strKey));
                                if (getData.GiftID == txtGiftID.val()) { break; } else { getData = ""; }
                            }
                        }
                        if (getData == "") {//新增
                            var giftlist = new Object();
                            giftlist.Type = "gift_" + retRndNum(3);
                            giftlist.GiftID = txtGiftID.val();
                            giftlist.ConvertNumber = $("#number").text();
                            xxl.xd.setValue(giftlist.Type, JSON.stringify(giftlist));
                        } else { //编辑
                            getData.ConvertNumber = parseInt(getData.ConvertNumber) + parseInt($("#number").text());
                            xxl.xd.setValue(getData.Type, JSON.stringify(getData));
                        }
                        var cookieStr = "";
                        for (var i = 0; i < localStorage.length; i++) {
                            strKey = localStorage.key(i);
                            if (strKey.substring(0, 5) == "gift_") {
                                getData = JSON.parse(xxl.xd.getValue(strKey));
                                cookieStr += getData.GiftID + ',' + getData.ConvertNumber + '|';
                            }
                        }
                        setCookie("giftlist", cookieStr);
                        var result = confirm("添加成功，要结算吗？");
                        if (result) { $("#go").click(); } else { $("#goBack").click(); }
                    }
                })

            </script>


            <footer data-role="footer" data-position="fixed" id="giftdetail_footer">
                <div data-role="navbar" id="nav-glyphish-example">
                    <ul>
                        <li><a href="#index" id="A5"><img src="images/business_site_btn.png" /><br/>商家网站</a></li>
                        <li><a href="#" onclick="openshoplist()"><img src="images/Goods_Book_btn.png" /><br/>商品购买</a></li>
                        <li><a href="#membershipcard" data-load="membershipcard.aspx" id="A7"><img src="images/member_card_btn.png" /><br/>会员卡</a></li>
                        <li class="footer_active"><a href="#giftlist" data-load="giftlist.aspx" id="A8" class="ui-btn-active"><img src="images/04.png" /><br/>积分兑换</a></li>
                    </ul>
                </div>
            </footer>

        </section>
    </div>
</body>
</html>



